<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
// ------------------------------------------------------------------------

function get_path($file, $path) 
{			
	$CI =& get_instance();	
        $lg = $CI->load->_ci_cached_vars['lang']['folder'];                
        
        $skin_path = $CI->template->get_skin_path();        
                                                	
	if ($skin_path!=FALSE)
	{                    
		$theme_path = $skin_path.$path;
	
	} else {
		$theme_path = 'assets/'.$path;
        }
        
        $file_lang = $theme_path.$lg.'/'.$file;
        if (file_exists($file_lang))
        {
                return base_url().$file_lang;
        }
        elseif (file_exists($theme_path.$file))
        {
                return base_url().$theme_path.$file;
        }                 			
}

function hook($hook_name, $hooks=FALSE) {
    $CI =& get_instance();	
    if ($hooks==FALSE) 
        $hooks = $CI->load->_ci_cached_vars['template']['hooks'];    
        
    foreach ($hooks as $name => $p) {                
        if ($name==$hook_name) {                                    
            foreach ($p as $item) {
                echo $item;                
            }
            return TRUE;
            // bo xung sap xep cac thanh phan sau
        }        
    }    
    return FALSE;
}

function widget_area($area_name, $widget=FALSE) {
    $CI =& get_instance();
}

// ------------------------------------------------------------------------

function style($file, $path=FALSE, $attributes = '')
{
	if (empty($file)) return;	
	return '<link type="text/css" rel="stylesheet" href="'. get_path($file, $path) .'" '.$attributes.' />' . "\n";	
}

function script($file, $path='js')
{
	if (empty($file)) return;
	return '<script src="'. get_path($file, $path) .'" type="text/javascript" charset="utf-8"></script>' . "\n";
}

function image($file, $attributes = '', $path='img')
{
	if (empty($file)) return;	
	return '<img src="'. get_path($file, $path) .'" '.$attributes.' />' . "\n";	
}

// EOF
?>